import time
file1=open('m1_sorted.txt')
file2=open('m2_reverse.txt')
file3=open('m3_shuffle.txt')

a=[]
for i in range(5000):
    a.append(int(file1.readline()))
t1=time.time()
for i in range(5000-1):
    k=0
    for j in range(len(a)-i-1):
        if a[j]>a[j+1]:
            a[j], a[j+1]=a[j+1], a[j]
            k+=1
    if k == 0:
        break
t2=time.time()
print("m1_sorted.txt", round((t2-t1)*1000), "milliseconds")


b=[]
for i in range(5000):
    b.append(int(file2.readline()))
t3=time.time()
for i in range(5000-1):
    k=0
    for j in range(len(b)-i-1):
        if b[j]>b[j+1]:
            b[j], b[j+1]=b[j+1], b[j]
            k+=1
    if k == 0:
        break
t4=time.time()
print("m2_reverse.txt", round((t4-t3)*1000), "milliseconds")


c=[]
for i in range(5000):
    c.append(int(file3.readline()))
t5=time.time()
for i in range(5000-1):
    k=0
    for j in range(len(c)-i-1):
        if c[j]>c[j+1]:
            c[j], c[j+1]=c[j+1], c[j]
            k+=1
    if k == 0:
        break
t6=time.time()
print("m3_shuffle.txt", round((t6-t5)*1000), "milliseconds")


        
